#coding=utf-8

from django.contrib import admin
from report.models import Report, ReportReason




def complete_checking(modeladmin, request, queryset):
    queryset.update(is_checked=True)
complete_checking.short_description = u"审核完成"

class ReportAdmin(admin.ModelAdmin):
    list_display=('user', 'content_type','object_pk', 'content_object', 'is_checked', 'created_time') 
    list_filter = ('user', 'times', 'is_checked', 'created_time')   
    
    actions = [complete_checking]
    
    def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None):
        context.update({"obj":obj});
        return super(ReportAdmin, self).render_change_form(request, context, add, change, form_url, obj)

    
class ReportReasonAdmin(admin.ModelAdmin):
    list_display=('content_type', 'reason',  'created_time') 

    
admin.site.register(Report, ReportAdmin)
admin.site.register(ReportReason, ReportReasonAdmin)
#admin.site.register(Report)